<template>
  <el-dialog
    v-dialogDrag
    title="统计"
    :visible.sync="visible"
    width="1000px"
    append-to-body
  >
    <Table :tableData="tableData" ref="table" />

    <pagination
      v-show="tableData.total > 0"
      :total="tableData.total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getListByPage"
    />

  </el-dialog>
</template>

<script>
import { getProjectDoctorData } from '@/api/trainProject'
import { configProjectTableFrame } from './frameData'

export default {
  name: "analysisDialog",
  data() {
    return {
      title: "",
      visible: false,
      loading: false,
      tableData: {
        loading: false,
        columns: configProjectTableFrame,
        total: 0,
        data: [],
      },
      id: null,
      queryParams: {
        pageNum: 1,
        pageSize: 10
      },
    };
  },
  methods: {
    getListByPage(){
      this.loading = false;
      const params = {
        pageNum: this.queryParams.pageNum,
        pageSize: this.queryParams.pageSize,
        projectId: this.id
      }

      getProjectDoctorData(params).then(res => {
        if(res.rows && res.rows.length >= 0){
          res.rows.forEach((row, index) => {
            row.num = (this.queryParams.pageNum - 1) * 10 + index + 1
          })
        }
        this.tableData.data = res.rows;
        this.tableData.total = res.total;
        this.loading = false;
      }).catch(() => {
        this.loading = false;
      })
    },

    showDialog(data) {
      this.visible = true
      this.id = data.id
      this.getListByPage()
    },

    cancel() {
      this.visible = false;
    },
  },
};
</script>
<style scoped lang="scss">

</style>
